home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / reader_requests / wild / support / wilf / modules / loadmeta.c < prev    next >
C/C++ Source or Header  |  2000-02-23  |  2KB  |  86 lines

  1. #include <exec/types.h>
  2. #include <inline/dos.h>
  3. #include <IO.h>
  4. #include <Strings.h>
  5. #include <meta.h>
  6. #include <exec/exec.h>
  7. extern struct Library *DOSBase;
  8. extern struct ExecBase *SysBase;
  9.  
  10. #define MAXIN    256
  11.  
  12. ULONG *LoadMETA(char *file)
  13. {
  14.  ULONG *fh;
  15.  if (fh=Open(file,MODE_OLDFILE))
  16.   {
  17.    int chk=NULL;
  18.    char linein[MAXIN];
  19.    char use[32];
  20.    struct Meta *meta;                // current meta
  21.    struct Group *group;                // current group
  22.    struct Entity *enty;                // current entity
  23.    struct Common *com;                // current object to define attrs
  24.    meta=NewMeta(0L);
  25.    com=meta;
  26.    while (LineInput(fh,linein,MAXIN))
  27.     {
  28.      switch (linein[0])
  29.       {
  30.        case META_STARTER:
  31.         {
  32.          chk++;
  33.          if (ChkIn(&linein[1],"Group"))
  34.           {
  35.            CopyWord(use,NextWord(&linein[1]));
  36.            group=NewGroup(meta,use);           
  37.            com=group;
  38.            break;
  39.           }
  40.          if (ChkIn(&linein[1],"Entity"))
  41.           {
  42.            int ID;
  43.            CopyWord(use,NextWord(&linein[1]));
  44.            StrToLong(use,&ID);
  45.        enty=NewEntity(group,meta,ID);
  46.        com=enty;
  47.        break;
  48.           }
  49.         break;                // GCC BUG WAR
  50.         }
  51.        case META_FINISHER:
  52.         {
  53.          chk--;
  54.          if (ChkIn(&linein[1],"Group"))
  55.           {
  56.            com=meta;
  57.            break;
  58.           }
  59.          if (ChkIn(&linein[1],"Entity"))
  60.           {
  61.        com=group;
  62.        break;
  63.           }
  64.         break;                // GCC BUG WAR
  65.         }        
  66.        case META_ATTR:
  67.         {
  68.          NewAttr(com,meta,&linein[1],NextWord(&linein[1]));
  69.          break;
  70.         }
  71.        case META_FLAG:
  72.         {
  73.          NewFlag(meta,&linein[1],NextWord(&linein[1]));
  74.          break;
  75.         }       
  76.       }      
  77.     }
  78.    return(meta);
  79.   } 
  80.  return(FALSE);
  81. }
  82.  
  83. void    FreeMETA(struct Meta *meta)
  84. {
  85.  DeletePool(meta->meta_Pool);
  86. }